# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_docker//container:container.bzl", "container_image")
load("//bazel:pl_build_system.bzl", "pl_cc_library", "pl_cc_test")

package(default_visibility = ["//src:__subpackages__"])

pl_cc_library(
    name = "cc_library",
    srcs = glob(
        ["*.cc"],
        exclude = ["*_test.cc"],
    ),
    hdrs = glob(["*.h"]),
    deps = [
        "//src/common/exec:cc_library",
    ],
)

container_image(
    name = "sleep_container_image",
    base = "@base_image_debug//image",
    cmd = [
        "-c",
        "echo started & sleep 100000000",
    ],
    entrypoint = ["/busybox/sh"],
)

# This test is useful for debugging flakiness on Jenkins BPF worker nodes,
# where there is some non-deterministic issues where containers fail to deploy.
# Mark as manual, since it is primarily for debugging, and could fail.
pl_cc_test(
    name = "container_runner_test",
    srcs = ["container_runner_test.cc"],
    data = [":sleep_container_image.tar"],
    tags = [
        "manual",
        "no_asan",
        "no_tsan",
        "requires_root",
    ],
    deps = [
        ":cc_library",
    ],
)
